<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <title>家庭记账本 - 登录</title>
    <meta charset="UTF-8">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body { font-family: Arial, sans-serif; background: #f5f5f5; }
        .login-container {
            width: 350px; margin: 100px auto; padding: 30px; background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }
        .login-container h2 { text-align: center; margin-bottom: 24px; }
        .form-group { margin-bottom: 18px; }
        .form-group label { display: block; margin-bottom: 6px; }
        .form-group input {
            width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px;
        }
        .login-btn {
            width: 100%; padding: 10px; background: #007bff; color: #fff; border: none; border-radius: 4px; font-size: 16px; cursor: pointer;
        }
        .login-btn:hover { background: #0056b3; }
        .error-msg { color: #d9534f; text-align: center; margin-bottom: 12px; }
    </style>
</head>
<body>
    <div class="container-fluid d-flex align-items-center justify-content-center" style="height: 100vh;">
        <div class="card p-4 shadow" style="min-width: 320px;">
            <h2 class="mb-4 text-center">家庭记账本登录</h2>
            <% String error = request.getParameter("error");
               if (error != null) { %>
                <div class="alert alert-danger text-center">用户名或密码错误</div>
            <% } %>
            <form action="login" method="post">
                <div class="mb-3">
                    <label for="username" class="form-label">用户名</label>
                    <input type="text" class="form-control" id="username" name="username" required autocomplete="off">
                </div>
                <div class="mb-3">
                    <label for="password" class="form-label">密码</label>
                    <div class="input-group">
                        <input type="password" class="form-control" id="loginPassword" name="password" required autocomplete="off">
                        <button class="btn btn-outline-secondary" type="button" id="toggleLoginPassword" tabindex="-1">
                            <i class="bi bi-eye" id="loginPasswordIcon"></i>
                        </button>
                    </div>
                </div>
                <button type="submit" class="btn btn-primary w-100">登录</button>
            </form>
            <div class="mt-3 text-center">
                <a href="register.jsp">注册账户</a>
            </div>
        </div>
    </div>
</body>
<script>
    document.getElementById('toggleLoginPassword').onclick = function() {
        var pwd = document.getElementById('loginPassword');
        var icon = document.getElementById('loginPasswordIcon');
        if (pwd.type === 'password') {
            pwd.type = 'text';
            icon.classList.remove('bi-eye');
            icon.classList.add('bi-eye-slash');
        } else {
            pwd.type = 'password';
            icon.classList.remove('bi-eye-slash');
            icon.classList.add('bi-eye');
        }
    };
</script>
<% if (request.getParameter("error") != null) { %>
<script>
    alert('用户名或密码错误');
</script>
<% } %>
</html> 